import com.demo.component.ArticleController;
import com.demo.component.BController;
import com.demo.component.UserComponent;
import com.demo.controller.StudentController;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @program: spring-demo2
 * @author: JCM
 * @create: 2023-06-11 17:36
 * @description:
 **/
public class App2 {
    public static void main1(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        User user = context.getBean(User.class);
        System.out.println(user.sayHi());
        User user1 = context.getBean("user",User.class);
        System.out.println(user1.sayHi());
    }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        ArticleController articleController =
                context.getBean("articleController", ArticleController.class);
//        articleController.saHi();

//        失败
//        BController bController =
//                context.getBean("bController",BController.class);
//        BController bController =
//                context.getBean("BController",BController.class);
//        bController.sayHi();

//        UserComponent userComponent =
//                context.getBean("userComponent",UserComponent.class);
//        userComponent.sayHi();

        StudentController studentController =
                context.getBean(StudentController.class);
        studentController.sayHi();

    }
}
